<!DOCTYPE html>
<script>
addEventListener('message', e => {
    fetch('./slow-response.php')
      .then(async response => {
          await internals.terminateServiceWorker(navigator.serviceWorker.controller);
          return response.text();
        })
      .then(() => {
          e.source.postMessage(
            'Ugr.. Canceled respondWith resolves the promise somehow.',
            e.origin);
        })
      .catch(() => {
          e.source.postMessage('Rejected successfully', e.origin);
        });
  });
</script>
